package dao;

import java.sql.SQLException;
import java.util.ArrayList;

import org.springframework.orm.ibatis.SqlMapClientTemplate;

import vo.MenuVO;

public class MenuDAO {
	private SqlMapClientTemplate client;
	
	public MenuDAO(){}
	
	public MenuDAO(SqlMapClientTemplate client){
		this.client = client;
	}
	
	public void insertMenu(MenuVO mvo) throws SQLException{
		client.insert("menuSql.insertMenu", mvo);
	}
	
	public void updateMenu(MenuVO mvo) throws SQLException{
		client.update("menuSql.updateMenu", mvo);
	}
	
	public void deleteMenu(String pid) throws SQLException{
		client.delete("menuSql.deleteMenu", pid);
	}
	
	public MenuVO selectMenuById(String pid) throws SQLException{
		return (MenuVO) client.queryForObject("menuSql.selectMenuByMenuId", pid);
	}
	
	@SuppressWarnings("unchecked")
	public ArrayList<MenuVO> selectAllMenu(String member_id) throws SQLException{
		return (ArrayList<MenuVO>) client.queryForList("menuSql.selectAllMenu", member_id);
	}
	
	public int selectCountMenu(String member_id){
		int count = (Integer) client.queryForObject("menuSql.selectCountMenu", member_id);
		return count;
	}
	
	
}
